import request, { axiosOptions, axiosRequest } from '@/utils/request'

// 查询角色列表
export function getRoles(query){
  const options=axiosOptions('get');
  return axiosRequest("/role/getRoles",query,options)
}

/**
 * 根据角色id获取角色列表
 * @param ids
 * @returns {Promise<unknown>}
 */
export function getRolesById(ids){
  const options=axiosOptions(null,"application/json");
  return axiosRequest("/role/getRolesByIds",JSON.stringify({'getIds':ids}),options);
}

// 删除角色
export function delRole(ids) {
  let options = axiosOptions(null,"application/json");
  return axiosRequest("/role/delete",JSON.stringify({'deleteIds':ids}),options)
}

// 新增角色
export function addRole(data) {
  let options = axiosOptions(null,"application/json");
  return axiosRequest("/role/addOrEdit",JSON.stringify(data),options)
}

//根据角色获取所拥有的资源
export function getResourceByRole(roleId){
  let options = axiosOptions('get',null);
  return axiosRequest("/role/getResourceByRole",{"roleId":roleId},options)
}

//新增编辑角色
export function addOrEdit(role){
  let options = axiosOptions(null,"application/json");
  return axiosRequest("/role/addOrEdit",JSON.stringify(role),options)
}

